#include <stdio.h>
#include <pthread.h>
#include <string.h>
int main(int argc,char* argv[])
{
	if(argc < 2)
	{
		printf("incorrect parameter\n");
		return 1;
	}
	pthread_mutexattr_t attr;
	if(strcmp(argv[1],"normal") == 0)
	{
		pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_NORMAL);
	}
	else if(strcmp(argv[1],"recursive") == 0)
	{
		pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
	}
	else if(strcmp(argv[1],"errorcheck") == 0)
	{
		pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_ERRORCHECK);
	}
	else
	{
		pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_DEFAULT);
	}
	pthread_mutex_t lock;
	pthread_mutex_init(&lock,&attr);
	if(pthread_mutex_lock(&lock) != 0)
	{
		printf("first lock error\n");
	}
	else
	{
		printf("first lock\n");
	}
	if(pthread_mutex_lock(&lock) != 0)
	{
		printf("secound lock error\n");
	}
	else
	{
		printf("second lock\n");
	}
	pthread_mutex_destroy(&lock);
	pthread_mutexattr_destroy(&attr);
	return 0;
}
